import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

public class Solution901 {

    int cur=-1;
    List<Integer> list=new ArrayList<>();
    Stack<Integer> stack=new Stack<>();

    public Solution901() {

    }

    public int next(int price) {
        cur++;
        while (!stack.isEmpty() && price>=list.get(stack.peek())){
            stack.pop();
        }
        int t=cur;
        if (stack.isEmpty()){
            t++;
        }else{
            t-=stack.peek();
        }
        list.add(price);
        stack.push(cur);
        return t;
    }

    public static void main(String[] args) {
        Solution901 solution901=new Solution901();
        System.out.println(solution901.next(100));
        System.out.println(solution901.next(80));
        System.out.println(solution901.next(60));
        System.out.println(solution901.next(70));
        System.out.println(solution901.next(60));
        System.out.println(solution901.next(75));
        System.out.println(solution901.next(85));
    }
}
